<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../lib/layui/css/layui.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>生产管理</title>
</head>
<body>
    <div class="pt-5  pl-20 pr-20 pb-20">
        <form id="itemEdit" name="itemEdit" method="post" action="../ashx/spui.ashx" class="form form-horizontal">
            <input type="hidden" class="actionValue" id="editAction" name="action" value="add" />
            <input type="hidden" id="id" name="id" />
            <input type="hidden" id="fgid" name="fgid" value="" />
            <input type="hidden" id="tablename" name="tablename" value="" />
            <input type="hidden" id="tablemidname" name="tablemidname" value="" />
            <input type="hidden" id="dataneedtouser" name="dataneedtouser" value="1" /><!--是否要包含通用数据必归属处理-->
            <input type="hidden" id="ftype" name="ftype" value="生产任务" />
            <input type="hidden" id="ywcheckonly" name="ywcheckonly" value="ftaskno#当前生产编号已存在!" />
            <input type="hidden" id="ftaskbfmj" name="ftaskbfmj" value="0" /><!--报废面积-->
            <div id="tab-category" class="HuiTab">
                <div class="tabBar cl" id="tab-categorybar"><span>生产任务</span><span>所用地块</span><span>其它信息</span></div>
                <div class="tabCon" id="divtab1">
                    <div id="divshow1">
                        <div class="row cl">
                            <label class="form-label col-1">编号：</label>
                            <div class="formControls col-2">
                                <input type="text" class="input-text" name="ftaskno" id="ftaskno" placeholder="生产编号" value="" />
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">片区：</label>
                            <div class="formControls col-2">
                                <span class="select-box">
                                    <select class="select" size="1" name="fareaid" id="fareaid">
                                    </select>
                                </span>
                                <input type="hidden" id="fareaname" name="fareaname" value="" />
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">品种：</label>
                            <div class="formControls col-2  layui-form">
                                <select name="ftasksctype" id='ftasksctype' lay-filter="layseltasksctype" lay-verify="required" nullmsg="不能为空" datatype="*1-22"  lay-search="">
                                    <option value="">直接选择或搜索选择</option>
                                </select>
                                <input type="hidden" id="ftasksctypename" name="ftasksctypename" value="" />
                            </div>
                            <div class="col-1"></div>
                        </div>
                        <div class="row cl">
                            <label class="form-label col-1">计划总面积：</label>
                            <div class="formControls col-2">
                                <input type="text" class="input-text" name="ftaskmj" id="ftaskmj" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">播种时间：</label>
                            <div class="formControls col-2">
                                <input type="text" nullmsg="不能为空" datatype="*4-22" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="ftaskstarttime" id="ftaskstarttime" class="input-text Wdate" />
                            </div>
                            <div class="col-1"></div>
                        </div>
                        <div class="row cl">
                            <label class="form-label col-1">每次播种面积：</label>
                            <div class="formControls col-2">
                                <input type="text" class="input-text" name="fbjtimecount" id="fbjtimecount" nullmsg="不能为空" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">播种间隔（天）：</label>
                            <div class="formControls col-2">
                                <input type="text" class="input-text" name="fbjdaysplit" id="fbjdaysplit" nullmsg="不能为空" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">播种次数：</label>
                            <div class="formControls col-2">
                                <input type="text" class="input-text" name="fbjcount" id="fbjcount" nullmsg="不能为空" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                            </div>
                            <div class="col-1"></div>
                        </div>
                        <div class="row cl">
                            <label class="form-label col-1">状态：</label>
                            <div class="formControls col-2">
                                <span class="select-box">
                                    <select class="select" size="1" name="ftaskstatus" id="ftaskstatus">
                                        <option value="计划">计划</option>
                                        <option value="种植">种植</option>
                                        <option value="完成">完成</option>
                                        <option value="中止">中止</option>
                                    </select>
                                </span>
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">预计采收时间：</label>
                            <div class="formControls col-2">
                                <input type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" name="ftaskendtime" id="ftaskendtime" class="input-text Wdate" />
                            </div>
                            <div class="col-1"></div>
                            <label class="form-label col-1">预计采收量：</label>
                            <div class="formControls col-2">
                                <input type="text" class="input-text" name="ftaskallget" id="ftaskallget" value="0" datatype="/^-?[1-9]+(\.\d+)?$|^-?0(\.\d+)?$|^-?[1-9]+[0-9]*(\.\d+)?$/" placeholder="2~10个长度" />
                            </div>

                        </div>
                        <div class="row cl">
                            <label class="form-label col-1">任务说明：</label>
                            <div class="formControls col-5">
                                <input type="text" class="input-text" name="ftaskinfo" id="ftaskinfo" placeholder="任务说明" />
                            </div>
                            <div class="col-1"></div>
                        </div>
                    </div>
                </div>
                <div class="tabCon" id="divtab2">
                    <div id="divshow2">
                        <div class="panel panel-default    mt-20">
                            <div class="panel-header"><a href="javascript:;" onclick="addTaskDcInfo()" class="btn btn-danger  round"><i class="Hui-iconfont">&#xe600;</i>添加要用的地块</a></div>
                            <div>
                                <table class="table table-border table-bordered table-striped table-hover" id="tablelist" width="100%">
                                    <thead>
                                        <tr class="text-c">
                                            <th width="30"><a id="hcmtable_sall" onclick="hcmtable_sall();" href="javascript:;" title="全选反选"><i class="Hui-iconfont">&#xe608;全</i></a></th>
                                            <th>地块编号</th>
                                            <th>所有面积</th>
                                            <th>说明</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tabCon" id="divtab3">
                    <div id="divshow3">
                    </div>
                </div>
            </div>
            <div class="cl" style="display: none;" id="fold_category">
                <ul id="Huifold2" class="Huifold">
                    <li class="item">
                        <h4>生产任务<b>+</b></h4>
                        <div class="info" id="divfold1" style="display: block;">
                        </div>
                    </li>
                    <li class="item">
                        <h4>基本设置2<b>+</b></h4>
                        <div class="info" id="divfold2" style="display: block;">
                        </div>
                    </li>
                    <li class="item">
                        <h4>基本设置3<b>+</b></h4>
                        <div class="info" id="divfold3" style="display: block;"></div>
                    </li>
                </ul>
            </div>
            <div class="row cl">
                <div class="col-6 col-offset-4">
                    <button onclick="changeshowtype();" class="btn btn-danger radius" type="button">切换显示</button>&nbsp;&nbsp;&nbsp;&nbsp;
                    <button class="btn btn-primary radius" type="submit" id="btsub1">提交</button>&nbsp;&nbsp;
				<button class="btn btn-secondary radius" type="button" id="btn_reset">重置</button>&nbsp;&nbsp;
                  <button onclick="printPDF();" class="btn btn-default radius" type="button">打印</button>
                    <button onclick="layer_close();" class="btn btn-default radius" type="button">返回</button>
                </div>
            </div>
            <div class="row cl">
                <div class="col-10" id="divforhcrfbutton">
                </div>
            </div>
        </form>
    </div>
    <iframe style="display: none" id="printIframe"></iframe>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layui/layui.js"></script>
    <script type="text/javascript" src="../lib/icheck/jquery.icheck.min.js"></script>
    <script type="text/javascript" src="../lib/Validform/5.3.2/Validform.js"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_au.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>

    <script type="text/javascript" src="../lib/datatables/1.10.0/jtable.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>

    <script type="text/javascript">
        //Mhcloadback[0] = "ftasksctype";
        HcUiAuloadInfoAuto = false;//将自动加载，设置为false（禁用自动加载）
        spsetBaseNoBt("hsc_task", "id", "hsc_task as T", "*", "#tablelist", "hsc_task", "生产任务管理", "sctasklist-ae");
        hcui_ajaxasync = false;
        //种植物
        hcdoselbyPost("id,fv1 as name", "yw_baseinfo", "type=1 and maintype=1", "", "", "id",
               function (data) {
                   SetSelectWithArrayIdName("#ftasksctype", data);
                   if (uiform) uiform.render('');//这个好像不用再保留了
               });
        hcui_ajaxasync = true;
        var uiform = null;


        //加载处理
        function loadin() {
            //加载区域
            hcdoselbyPost("id,fv1 as name", "yw_baseinfo", "type='5' and  maintype='5' and databranchid=" + HCUser.HCUorg, "", "", "id",
                   function (data) {
                       SetSelectWithArrayIdName("#fareaid", data);
                   });

            layui.use(['form'], function () {
                uiform = layui.form();

                //因为这个慢，所在加载要从这个开始
                loadInfoById(aumid, function (data) {
                    loadback(data);
                });
                uiform.on('select(layseltasksctype)', function (data) {
                    $('#ftasksctypename').val($("#ftasksctype").find("option:selected").text());
                });
            });

            if (getUrlParam("action") == "add") {
                $("#fgid").val(NewGuid());
                console.log(HCUser);
                $("#ftaskno").val(HCUser.HCUorgCode + (new Date()).Format("yyyyMMddhhmmss"));

            }
            $.Huitab("#tab-category .tabBar span", "#tab-category .tabCon", "current", "click", "0");
            $.Huifold("#Huifold2 .item h4", "#Huifold2 .item .info", "", 3, "click");
        }

        function loadback(data) {
            uiform.render();//这个不能去掉,坑啊
            //列表信息加载
            if (aumid) {
                hcmtable = $("#tablelist").DataTable({
                    "serverSide": true,
                    "bFilter": false,
                    "bLengthChange": false,
                    "ajax": {
                        "type": "POST",
                        "url": sposelUrl("hsc_task_info", "*", " and taskid=" + aumid + " and infotype=1 and infobytype1=1") + "&sporderby=id",
                        "data": function (d) {
                        }
                    },
                    aLengthMenu: [100],
                    "columns": [
                         { "data": "rowhcindex" }
    , { "data": "infofv1" }
    , { "data": "infonv1" }
   , { "data": "infofv2" }
    , { "data": "id" }
                    ],
                    "columnDefs": [
                        {
                            "targets": [4],
                            "render": function (data, type, row) {
                                return "<a style=\"text-decoration:none\" class=\"ml-5\" onclick=\"toolUpdateById('" + data + "','','')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
                                       "<a style=\"text-decoration:none\" class=\"ml-5\" onclick=\"toolDelete('" + data + "','hsc_task_info','id')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>";
                            }
                        },

                    {
                        "orderable": false,
                        "targets": [0, 1, 2, 3]
                    }
                    ]
                });
            }
        }

        function addTaskDcInfo() {
            if (aumid != "" && aumid != null && aumid != 'undefined') {
                toolAdd("添加所用地块信息", "sctasklist-ae-ae.html?action=add&maintype=" + aumid, 850, 400);
            }
            else {
                layer.alert("请在编辑情况下操作", { icon: 1 });
            }
        }
    </script>
    <script type="text/javascript">

        //提交数据后,回调
        function subback(data) {

            if (auhcotype == "add" && data.status == "y") {
                layer.confirm('添加成功!', {
                    btn: ['确定'] //按钮
                }, function (index) {
                    layer_close();
                }, function (index) {
                    layer_close();
                });
            }
            else {
                if (data.status == "y") {
                    layer.alert(data.info, { icon: 1 });
                }
                else {
                    layer.alert(data.info, { icon: 2 });
                }
            }
        }

        var divshowtype = 1;
        //切换事件
        function changeshowtype() {
            if (divshowtype == 1) {
                $("#divshow1").appendTo("#divfold1");
                $("#divshow2").appendTo("#divfold2");
                $("#divshow3").appendTo("#divfold3");
                $("#fold_category").show();
                $("#tab-category").hide();
                divshowtype = 2;
            }
            else {
                $("#divshow1").appendTo("#divtab1");
                $("#divshow2").appendTo("#divtab2");
                $("#divshow3").appendTo("#divtab3");
                $("#fold_category").hide();
                $("#tab-category").show();
                divshowtype = 1;
            }
        }
        //重写  提交前数据处理
        function hcrBeforeSub() {
            $("#fareaname").val($('#fareaid option:selected').text());
        }
    </script>
</body>
</html>
